/*****************************************************************************
 *
 *                      HUSONG PROPRIETARY INFORMATION
 *
 *          The information contained herein is proprietary to HUSONG
 *           and shall not be reproduced or disclosed in whole or in part
 *                    or used for any design or manufacture
 *              without direct written authorization from HUSONG.
 *
 *            Copyright (c) 2015 by HUSONG.  All rights reserved.
 *
 *****************************************************************************/
package me.send.business.service.mapper;

import java.util.Map;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import me.send.business.service.BaseMapper;

/**
 * @author maxmin
 *
 * @date 2015年8月7日 上午11:07:10
 */
public abstract interface OrderBrokerMapper extends BaseMapper{
	
	/**
	 * 用户选择经纪人
	 * @param params
	 * @return
	 */
	@Update(value = "UPDATE orderbroker SET ischecked = 1 WHERE order_broker_id=#{orderBrokerId} AND ischecked=0")
	public abstract int checkBroker(Map<String, Object> params);
	
	@Select(value = "SELECT isvAccountId FROM orderbroker ob,popuser pu WHERE ob.broker_id = pu.popid AND order_broker_id=#{orderBrokerId}")
	public abstract String getBrokerNoticIdByOrderBrokerId(Long orderBrokerId);
	
	/**
	 * 修改订单状态为已接单
	 * @param params
	 * @return
	 */
	@Update (value = "UPDATE orders SET `status` = 3 WHERE orderid = #{orderid}")
	public abstract int updateOrderStatus(int orderid);
	
	/**
	 * 修改订单状态为已接单
	 * @param params
	 * @return
	 */
	@Update (value = "UPDATE orders SET `status` = 3,brokerid=#{brokerid} WHERE orderid = #{orderid}")
	public abstract int updateOrderStatusAndBrokerId(Map<String, Object> params);
	
	/**
	 * 获取经纪人ID
	 * @param orderBrokerId
	 * @return
	 * @author maxmin
	 * @date 2015年8月25日下午3:14:28
	 */
	@Select(value="SELECT popid FROM orderbroker ob,popuser pu WHERE ob.broker_id = pu.popid AND order_broker_id=#{orderBrokerId}")
	public abstract int getBrokerIdByOrderBrokerId(Long orderBrokerId);
}
